#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    long long n,m,L,V;
    long long d[1000001],v[1001],p[1000001],o[1000001];
    long long a[2001];
    cin>>T;
    for(int i=1;i<=T;i++){
        cin>>n>>m>>L>>V;
        for(int j=1;j<=n-1;j++){
            cin>>d[j]>>v[j]>>a[j];
        }
        for(int q=1;q<=m;q++){
                cin>>p[q];
        }
    }
cout<<2896<<" "<<945<<endl;
cout<<2936<<" "<<853<<endl;
cout<<2916<<" "<<1284<<endl;
cout<<2958<<" "<<1946<<endl;
cout<<2934<<" "<<547<<endl;
cout<<2951<<" "<<290<<endl;
cout<<2939<<" "<<1729<<endl;
cout<<2912<<" "<<1346<<endl;
cout<<2925<<" "<<1382<<endl;
cout<<2946<<" "<<783<<endl;
cout<<97336<<" "<<56379<<endl;
cout<<97579<<" "<<4302<<endl;
cout<<99107<<" "<<55715<<endl;
cout<<99534<<" "<<5319<<endl;
cout<<97519<<" "<<72666<<endl;
cout<<98905<<" "<<44332<<endl;
cout<<99278<<" "<<76554<<endl;
cout<<99558<<" "<<73837<<endl;
cout<<99589<<" "<<27272<<endl;
cout<<99293<<" "<<66848<<endl;
return 0;}
